import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/internal/Observable';
import { AppSettings, UserStatus } from '../config/app-settings';
import * as _ from 'lodash';
@Injectable({
    providedIn: 'root'
})
export class StatisticsUtilsService {

    constructor(private httpClient: HttpClient) {

    }

    getUserOrgTree(referID, level): Observable<any> {
        let header = _.cloneDeep(AppSettings.httpServerHeader);
        header.params = new HttpParams().set('referid', referID).set('level', level);
        return this.httpClient.get(`${AppSettings.server_base}/statistics/all-user-tree`, header);

    }

    /**
     * 获取treeTable
     * @param referID 
     */
    getSubAgentKPI(referID): Observable<any> {
        let header = _.cloneDeep(AppSettings.httpServerHeader);
        header.params = new HttpParams().set('referid', referID);
        return this.httpClient.get(`${AppSettings.server_base}/statistics/property`, header);

    }


    getSalesRecordStat(id) {
        let header = _.cloneDeep(AppSettings.httpServerHeader);
        header.params = new HttpParams().set('user', id);
        return this.httpClient.get(`${AppSettings.server_base}/statistics/agent-sales-record`, header);
    }
    getPropertyManagementStat(id) {
        let header = _.cloneDeep(AppSettings.httpServerHeader);
        header.params = new HttpParams().set('user', id);
        return this.httpClient.get(`${AppSettings.server_base}/statistics/agent-property-management`, header);
    }

}